]> git.r.bdr.sh - rbdr/Flat-Bezel.qsplugin/blobdiff - Flat Bezel/BBSearchObjectView.m
Remove half-swifts
[rbdr/Flat-Bezel.qsplugin] / Flat Bezel / BBSearchObjectView.m
index ba88b0bbc2f26ea256f879fd7eeb0e21838d979d..0722e0c25b38e212fb49912cee4c128b8a360666 100644 (file)
   [titleString drawInRect:centerRectInRect(centerRect, textDrawRect)];
 }
 
-@end
-
-
-
+- (void)drawSearchPlaceholderWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
+  NSString *defaultText = NSLocalizedStringWithDefaultValue(@"Type to search", nil, [NSBundle mainBundle], @"Type to search", @"Hint that appears in the first pane of the QS interface when it's empty.");
+  NSSize textSize = [defaultText sizeWithAttributes:nameAttributes];
+  NSRect textRect = centerRectInRect(rectFromSize(textSize), cellFrame);
+  BOOL isFirstResponder = [[controlView window] firstResponder] == controlView && ![controlView isKindOfClass:[NSTableView class]];
+  
+  if (isFirstResponder && [controlView isKindOfClass:[QSSearchObjectView class]]) {
+    NSImage *find = [NSImage imageWithSystemSymbolName:@"magnifyingglass.circle.fill" accessibilityDescription:nil];
+    
+    
+    [find setSize:QSSize16];
+    NSRect findImageRect = expelRectFromRectOnEdge(centerRectInRect(rectFromSize([find size]), cellFrame), textRect, NSRectEdgeMinX, -2);
+    
+  
+    NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
+    [graphicsContext saveGraphicsState];
+    CGContextRef context = [graphicsContext CGContext];
+    CGContextBeginTransparencyLayerWithRect(context, findImageRect, nil);
+    CGContextSetBlendMode(context, kCGBlendModeNormal);
+    [find drawInRect:findImageRect fromRect:rectFromSize([find size]) operation:NSCompositingOperationSourceOver fraction:1];
+    CGContextSetBlendMode(context, kCGBlendModeSourceIn);
+    CGContextSetFillColorWithColor(context, [[NSColor textColor] CGColor]);
+    CGContextFillRect(context, findImageRect);
+    CGContextEndTransparencyLayer(context);
+
+    [defaultText drawInRect:textRect withAttributes:nameAttributes];
+  }
+}
 
+@end